package com.integrationpath.mengine.util;

import javax.servlet.http.HttpServletRequest;

import com.opensymphony.oscache.base.Cache;
import com.opensymphony.oscache.web.ServletCacheAdministrator;
import com.opensymphony.oscache.web.filter.ICacheKeyProvider;

public class CacheKeyProvider implements ICacheKeyProvider {

    public String createCacheKey(HttpServletRequest httpRequest, ServletCacheAdministrator scAdmin, Cache cache) {

        // buffer for the cache key
        StringBuffer buffer = new StringBuffer(500);
        
        // part 1 of the key: the request uri
        buffer.append(httpRequest.getRequestURI());
        
//        // separation
//        buffer.append('_');
//
//        // part 2 of the key: the page id
//        buffer.append(httpRequest.getParameter("pageid"));
//        
//        // separation
//        buffer.append('_');
//        
//        // part 3 of the key: the pagination
//        buffer.append(httpRequest.getParameter("pagination"));
        
        return buffer.toString();
    }

}
